#ifndef _HCHO_SENSOR_H_
#define _HCHO_SENSOR_H_

    #if defined(ARDUINO) && ARDUINO>=100
        #include "Arduino.h"
    #else
        #include "WProgram.h"
    #endif

    #include <SoftwareSerial.h>

    #define FRAME_HEAD1 0x42
    #define FRAME_HEAD2 0x4d

        //气体类型枚举
        enum enum_Unit
        {
            ppm = 0x01,
            VOL = 0x02,
            LEL = 0x03,
            Ppb = 0x04,
            Mgpm3 = 0x05
        };
    
        enum enum_Command
        {
            CMD_QUERY = 0x01,
            CMD_CLEAR = 0x02,
            CMD_SPAN = 0x03,
            CMD_RESET = 0x04
        };

    class HCHOSensor
    {
    public:
        HCHOSensor(int rxPin,int txPin);
        ~HCHOSensor();
        bool getValue();
        uint16_t check_sum(uint8_t* buf,uint16_t length);

        enum_Unit UnitID;
        uint8_t VH;
        uint16_t Data16;
        float HCHO_Value;
    private:
 
        
        void Cmd_Send(uint8_t cmd,uint16_t cmdData);

        SoftwareSerial* p_serial;


    };





#endif